package com.tlx.core.util;

import java.io.File;

import javax.annotation.PostConstruct;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.SpringApplication;
import org.springframework.core.env.Environment;
import org.springframework.stereotype.Component;

@Component
public class TConfig {

    // private Logger logger = LoggerFactory.getLogger(this.getClass());

    private static TConfig T_CONFIG;

    @Autowired
    private Environment env;

    @PostConstruct
    public void init() {
        T_CONFIG = this;
    }

    public static String getString(String key) {
        return T_CONFIG.env.getProperty(key);
    }

    public static int getInt(String key) {
        return Integer.parseInt(T_CONFIG.env.getProperty(key));
    }

    public static String getPath(String key) {
        return new File(getString(key)).getAbsolutePath();
    }

    public static void main(String[] args) {
        SpringApplication.run(TConfig.class, args);
        System.out.println(TConfig.getString("group.size"));
    }

}
